package myweka;

import weka.core.*;
import java.io.*;
import myio.*;

public class datamanipulator extends java.lang.Object{

    public static void main(String[] args){
	Instances iris = null;
	try{
	    FileReader reader = new FileReader("/home/jaeger/weka-3-5-5/data/iris.arff"); 
	    iris = new Instances(reader);
	}
	catch (IOException e) {System.out.println(e);}

	Instance nextinstance;
	double oldval;
	double newval;
	double scaleval;

	for (int i=0;i<10;i++){
	    Attribute nextattr = new Attribute("noise-"+i);
	    iris.insertAttributeAt(nextattr,iris.numAttributes());
	    scaleval = 5*Math.random();
	    for (int j=0;j<iris.numInstances();j++){
		nextinstance = iris.instance(j);
		newval = scaleval*Math.random();
		nextinstance.setValue(iris.numAttributes()-1,newval);
	    }
	}
	
// 	for (int i=0;i<iris.numInstances();i++){
// 	    nextinstance = iris.instance(i);
// 	    oldval = nextinstance.value(0);
// 	    newval = 100*oldval;
// 	    System.out.println("old: " + oldval + " new: " + newval);
// 	    nextinstance.setValue(0,newval);
// 	}

	try{
	    BufferedWriter bw = FileIO.openOutputFile("/home/jaeger/weka-3-5-5/data/iris_noise_10.arff");
	    bw.write(iris.toString());
	    bw.close();
	}
	catch (IOException e) {System.out.println(e);}

    }

}
